package cn.edu.zafu.bigdata.bd121.student.cli;

import cn.edu.zafu.bigdata.bd121.student.command.BaseCommand;
import cn.edu.zafu.bigdata.bd121.student.constant.StudentInfoConst;
import cn.edu.zafu.bigdata.bd121.student.entity.StudentPO;
import cn.hutool.json.JSONUtil;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Scanner;

/**
 * 管理系统CLI入口
 *
 * @author 202211090121
 */
public class CliMain {
    public static Scanner scanner = new Scanner(System.in);

    public static List<StudentPO> studentList = JSONUtil
            .readJSONArray(new File(StudentInfoConst.DB_PATH), StandardCharsets.UTF_8)
            .toList(StudentPO.class);


    public static void main(String[] args) {
        String input;
        do {
            Menu.showMenu();
            input = scanner.nextLine();
            BaseCommand command = Menu.selectMenu(input);
            command.execute();
        } while (!"5".equals(input));
    }
}
